﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace JiveMessenger.ValidationRules
{
    class GroupNameValidation : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if (value is string)
            {
                string inputString = (string)value;
                if (!inputString.All((x)=>
                    {
                        if(char.IsWhiteSpace(x) || char.IsLetterOrDigit(x))
                            return true;
                        else
                            return false;
                    }))
                    return new ValidationResult(false, "Group name must only contain letters or numbers");
            
            }
            return ValidationResult.ValidResult;
        }
    }
}
